package com.jiangyg.mall.authz.support.authentication.admin;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/**
 * 类描述：访问权限校验
 *
 * @author jiangyg
 * @version 4.0
 * @date 2021-10-12
 */
public class AdminAccessAuthentication implements Authentication {

    private static final long serialVersionUID = -8562405525531515192L;

    /**
     * token
     */
    private Object principal;

    /**
     * 待验证的请求地址
     */
    private Object credentials;

    /**
     * 用户信息
     */
    private Object details;

    public AdminAccessAuthentication(Object principal, Object credentials) {
        this.principal = principal;
        this.credentials = credentials;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public Object getCredentials() {
        return this.credentials;
    }

    @Override
    public Object getDetails() {
        return this.details;
    }

    public void setDetails(Object details) {
        this.details = details;
    }

    @Override
    public Object getPrincipal() {
        return this.principal;
    }

    @Override
    public boolean isAuthenticated() {
        return false;
    }

    @Override
    public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {
        if (isAuthenticated) {
            throw new IllegalArgumentException(
                    "Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead");
        }
    }

    @Override
    public String getName() {
        return null;
    }

}
